import { createStore, createLogger } from 'vuex'
import createPersistedstate from 'vuex-persistedstate'
import Cookies from 'js-cookie'

import user from './modules/user'
import cart from './modules/cart'
import category from './modules/category'

export default createStore({
  modules: {
    user,
    cart,
    category
  },
  plugins: [
    // createPersistedstate({
    //   key: 'erabbit-client-pc-store',
    //   paths: ['user', 'cart']
    // }),
    createPersistedstate({
      storage: {
        getItem: key => Cookies.get(key),
        setItem: (key, value) => Cookies.set(key, value, { expires: 7 }),
        removeItem: key => Cookies.remove(key)
      }
    }),
    createLogger()

  ]
})
